home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2005 May / PC för Alla 0505.iso / fullversioner / realsoft3d / data1.cab / Scripting / scripting / Intro / dynamic.js < prev    next >
Encoding:
Text File  |  2005-04-04  |  2.3 KB  |  78 lines

  1. // include javascript classes 
  2. include("oops/r3slider.js"); 
  3. include("oops/r3checkb.js"); 
  4. include("oops/r3window.js"); 
  5. include("oops/r3packer.js"); 
  6.  
  7. // Here is all the functionality needed to create dynamic
  8. // layouts. When the user clicks the check box, we set or clear
  9. // the Stealth attribute of appropriate packer and call FIT to
  10. // update the layout.
  11.  
  12. function showAdvanced(gadget, event, checked) 
  13.     if(event == R3OGM_GADGETUP) {
  14.         if(checked)
  15.             gadget.packer.SetStealth(FALSE);
  16.         else 
  17.             gadget.packer.SetStealth(TRUE);
  18.         gadget.window.FIT(R3WFP_BESTFIT);
  19.     }
  20.     return 1; 
  21.  
  22. // Rest of the code is very standard stuff then. 
  23.  
  24. window = new r3Window(R3WGA_Parent, _r3gui, 
  25.                 R3WGA_Left, 200, 
  26.               R3WGA_Top, 100, 
  27.               R3WA_Title, "Dynamic GUI", 
  28.               R3WA_ReportCloseWindow, TRUE, 
  29.               R3WA_ReportNewSize, TRUE); 
  30.  
  31. packer = new r3Packer(R3PA_Orientation, R3PAOF_VERTICAL); 
  32. window.SetGmanager(packer); 
  33.  
  34. // create fixed controls
  35. for(i = 0; i < 3; i++) { 
  36.     slider = new r3Slider(R3WGA_Parent, window,  
  37.               R3GA_Text, "Slider " + i); 
  38.     if(slider)
  39.         packer.ADD(R3PAPF_EXPAND | R3PAPF_FILLX | R3PAPF_FILLY, 0, slider); 
  40.  
  41.  
  42. // create a check box
  43. checkb = new r3Checkbox(R3RA_Hook, showAdvanced,
  44.                         R3WGA_Parent, window,
  45.                         R3GA_Text, "Advanced",
  46.                         R3GA_ToolTip, "Access advanced controls");
  47. if(checkb)
  48.     packer.ADD(R3PAPF_EXPAND | R3PAPF_FILLX | R3PAPF_FILLY, 0, checkb);
  49.  
  50. // create packer for the advanced controls
  51. // and insert couple of sliders to it.
  52. packAdvanced = new r3Packer(R3PA_Orientation, R3PAOF_VERTICAL);
  53. packer.ADD(R3PAPF_EXPAND | R3PAPF_FILLX, 0, packAdvanced);
  54.  
  55. for(i = 0; i < 2; i++) { 
  56.     slider = new r3Slider(R3WGA_Parent, window,  
  57.               R3GA_Text, "Advanced " + i); 
  58.     if(slider)
  59.         packAdvanced.ADD(R3PAPF_EXPAND | R3PAPF_FILLX, 0, slider);
  60.  
  61. // hide the advanced controls by default
  62. packAdvanced.SetStealth(TRUE);
  63.  
  64.  
  65. // tell checkbox where to find the advanced packer,
  66. // so that we can access it from the check boxe's callback function.
  67. checkb.packer = packAdvanced;
  68. checkb.window = window;
  69.  
  70. window.FIT(R3WFP_BESTFIT); 
  71. window.REALIZE();
  72.  
  73.  
  74.